/*
 * Swapping two values using call bye values is not possible as we have seen in last example.
 * but it can be achieved by call by reference. How?
 * In call by reference we are passing addresses of two values in called function and replacing value at that address.
 */

#include <stdio.h>

static void swapr(int *, int *);

int main()
{
	int a = 10;
	int b = 20;

	swapr(&a, &b);

	printf("a = %d\n", a);
	printf("b = %d\n", b);

	return 0;
}

static void
swapr(int *x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;

	printf("x = %d\n", *x);
	printf("y = %d\n", *y);
}
